class ShopController < ApplicationController
  layout "home"
  def index
  end

  def show
    @enterprise = Enterprise.find(params[:id])
    respond_to do |format|
      format.html 
      format.xml  { render :xml => @enterprise }
    end
  end
  
  def new
    @enterprise = Enterprise.new
    respond_to do |format|
      format.html # new.html.erb
      format.xml  #{ render :xml => @user }
    end
  end
  
  def create
    @enterprise = Enterprise.new(params[:enterprise])
#    @user_info = UserInfo.new(:city_id => params[:d_city][:id],:user_id => @user.id)
#    @user_detail = UserDetail.new(:user_id => @user.id)
#    @user.user_info = @user_info  
#    @user.user_detail = @user_detail
   
    respond_to do |format|
      if (@enterprise.save)    
        flash[:notice] = '商户添加成功.'
        format.html {  redirect_to(:action=>"show", :id=> @enterprise.id) }
         # format.xml  { render :xml => @user, :status => :created, :location => @user }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @enterprise.errors, :status => :unprocessable_entity }
      end
    end
  end

  def edit
  end

  def update
  end

  def destory
  end
end
